package com.item.yxlottery.yxlottery.base;

/*
 *------------------------------
 * @创建者      Administrator
 * @创建时间    2016/11/16 08:59
 * @文件描述    fragment的基类
 *------------------------------
 */

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment {

    public Context mContext;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (getActivity() != null && getActivity() instanceof BaseActivity) {
            mContext = getActivity();
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return initView(inflater, container);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
        initEvent();
    }

    /* 初始化控件 */
    protected abstract View initView(LayoutInflater inflater,ViewGroup container);

    /* 初始化数据 */
    protected abstract void initData();

    /* 事件处理 */
    protected abstract void initEvent();
}
